package org.yellow.backend.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yellow.backend.pojo.patient;
import org.yellow.backend.pojo.queue;
import org.yellow.backend.service.queueService;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author: hy
 * @create: 2024-01-01
 */
@Slf4j
@RestController
@RequestMapping("/queue")
public class queueController {
    @Autowired
    private queueService service;
    @GetMapping("/{id}")
    public queue getQueue(@PathVariable("id") int id){
        return service.selectQueueById(id);
    }

    @PostMapping("/insertNew/{urgency}")
    public boolean insertNew(@RequestBody patient patient,@PathVariable("urgency") int urgency) {
        log.info(patient.toString()+"urgency===>"+urgency);
        return service.insertNew(patient,urgency);
    }
    @PutMapping("/updateStatus/{queueId}")
    public boolean updateStatus(@PathVariable("queueId") int queueId){
        return service.updateStatus(queueId);
    }
    @DeleteMapping("/delete/{id}")
    public boolean deleteByPatientId(@PathVariable("id") int id){
        return service.deleteByPatientId(id);
    }
    @GetMapping("/getAll")
    public List<patient> showQueue(){
        return service.showQueue();
    }
    @GetMapping("/getAllById/{doctorId}")
    public List<Map<String,String>>  showActiveQueue(@PathVariable("doctorId") int doctorId){

        return service.showActiveQueue(doctorId);
    }
}
